package com.lkk.TicketFlow.common.exception;

public class BusinessException extends RuntimeException {

    private final BusinessExceptionEnum e;

    public BusinessException(BusinessExceptionEnum e) {
        super(e != null ? e.getMessage() : "业务异常"); // 关键修复：调用父类构造器
        this.e = e;
    }

    public BusinessExceptionEnum getE() {
        return e;
    }

    /**
     * 重写getMessage方法，确保返回正确的错误信息
     */
    @Override
    public String getMessage() {
        if (e != null && e.getMessage() != null) {
            return e.getMessage();
        }
        return super.getMessage();
    }

    /**
     * 不写入堆栈信息，提高性能
     */
    @Override
    public Throwable fillInStackTrace() {
        return this;
    }
}
